// 文章详情 - 接口
import axios from '@/utils/request.js'
// 文章 - 获取指定列表
export const articlesListAPI = ({ channel_id, page = 1 }) => {
  return axios({
    url: '/v1_1/articles', // 本地接口
    // url: '/v1_0/articles',
    params: {
      channel_id,
      timestamp: Math.floor(new Date().getTime()),
      with_top: 1,
      page
    }
  })
}

// 文章 - 不感兴趣
export const articlesDislikeAPI = ({ target }) => {
  return axios({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target
    }
  })
}

// 文章 - 举报
export const articleReportsAPI = ({ target, type }) => {
  return axios({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target: target,
      type: type
    }
  })
}

// 文章 - 获取详情
export const articleDetailAPI = ({ artId }) => {
  return axios({
    url: `/v1_0/articles/${artId}`
  })
}

// 文章 - 关注作者
export const authorFollowingAPI = ({ autId }) => {
  return axios({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target: autId
    }
  })
}

// 文章 - 取关作者
export const authorUnFollowingAPI = ({ autId }) => {
  return axios({
    url: `/v1_0/user/followings/${autId}`,
    method: 'DELETE'
  })
}

// 文章 - 点赞
export const articleAttitudeAPI = ({ artId }) => {
  return axios({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target: artId
    }
  })
}

// 文章 - 点赞
export const articleUnAttitudeAPI = ({ artId }) => {
  return axios({
    url: `/v1_0/article/likings/${artId}`,
    method: 'DELETE'
  })
}

// 文章 - 获取评论列表
export const commentListAPI = ({ artId, offset }) => {
  return axios({
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset: offset
    }
  })
}

// 文章 - 评论点赞
export const commentLikeAPI = ({ commentId }) => {
  return axios({
    url: '/v1_0/comment/likings',
    method: 'POST',
    data: {
      target: commentId
    }
  })
}
